package com.xt.cloud.kettle.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.PrintWriter;

/**
 * @author lj
 * @title: IndexController
 * @projectName data-kettle1
 * @description: TODO
 * @date 2022/4/2 00029:48
 */
@Controller
public class IndexController {

    @RequestMapping(value="/")
    protected String hello(HttpServletResponse response, HttpServletRequest request) throws Exception{
        HttpSession session=request.getSession();
        Object user = session.getAttribute("login");
        if (user != null) {
            return "/index";
        }else {
            return "/login";
        }
    }
    @RequestMapping(value="/index")
    protected String index(HttpServletResponse response, HttpServletRequest request) throws Exception{
        HttpSession session=request.getSession();
        if (null != session.getAttribute("login")) {
            return "/index";
        } else {
            return "/login";
        }
    }
    @RequestMapping(value="/exception")
    protected String exception(HttpServletResponse response, HttpServletRequest request) throws Exception{
        return "/exception";
    }
}
